package com.ymsoft.myerp.task;

import com.ymsoft.myerp.socketio.PushMessage;
import com.ymsoft.myerp.socketio.SocketIOService;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

public class HiJob extends QuartzJobBean {
    protected Logger log = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private SocketIOService socketIOService;

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        for(String username : socketIOService.getMaps().keySet()) {
            PushMessage pushMessage = new PushMessage();
            pushMessage.setUsername(username);
            pushMessage.setContent("测试消息推送");
            socketIOService.pushMessageToUser(pushMessage);
        }
    }
}